package
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import view.components.MenuButtonView;
	
	[ SWF( width = "800", height = "600", frameRate = "30", backgroundColor ="#FFFFFF" ) ]
	public class Main extends Sprite
	{
		
		private var bckgrd:Sprite;
		
		public function Main()
		{
			bckgrd = new Sprite();
			addChild( bckgrd );
			
			addEventListener( Event.ADDED_TO_STAGE, addedToStageHandler, false, 0, true );
		}
		
		public function init():void
		{
			
			var g:Graphics = bckgrd.graphics;
			g.clear();
			g.beginFill(0xFFFFFF, 1);
			g.drawRect(0, 0, ApplicationFacade.APP_WIDTH, ApplicationFacade.APP_HEIGHT );
			g.endFill();
			
			FX.growShadow( bckgrd, { color:0x222222, alpha:0.5, val:10, angle:90, dist:5 } );
		}
		
		private function addedToStageHandler( e:Event ):void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.showDefaultContextMenu = true;
			
			ApplicationFacade.getInstance().startup( this );
			
			stageResize( null );
			stage.addEventListener( Event.RESIZE, stageResize );
		}
		
		private function stageResize( e:Event ):void
		{
			this.x = Math.round( (stage.stageWidth / 2) - (ApplicationFacade.APP_WIDTH / 2) );
			this.y = Math.round( (stage.stageHeight / 2) - (ApplicationFacade.APP_HEIGHT / 2) );
		}
	}
}